/* GUI CONVERTED from ecclose.p (converter v1.76) Tue Dec 31 10:45:02 2002 */
/* ecclose.p - PCR/PCO CLOSE                                            */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.9.1.6 $                                                     */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 7.4      LAST MODIFIED: 12/30/93   BY: pma *H013*          */
/* REVISION: 7.4      LAST MODIFIED: 04/10/95   BY: jpm *H0CH*          */
/* REVISION: 8.5      LAST MODIFIED: 11/22/95   BY: tvo *J094*          */
/* REVISION: 8.5      LAST MODIFIED: 07/31/96   BY: *G2BB*  Russ Witt   */
/* REVISION: 8.5      LAST MODIFIED: 08/13/96   BY: *H0M8*  Russ Witt   */
/* REVISION: 8.6      LAST MODIFIED: 11/22/96   BY: Ashley Kurien *K00C*    */
/* REVISION: 8.6      LAST MODIFIED: 03/19/97   BY: Verghese Kurien *K087*  */
/* REVISION: 8.6      LAST MODIFIED: 10/07/97   BY: John Worden     *K0LP*  */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane        */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder    */
/* $Revision: 1.9.1.6 $    BY: Katie Hilbert        DATE: 12/27/02  ECO: *P0L8*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* DISPLAY TITLE */
{mfdtitle.i "2+ "}
define shared variable global_recid as recid.

define variable doc        as character.
define variable nbr        like ecm_nbr label "Number".
define variable ecmid      like wo_lot.
define variable dbase      like si_db.
define variable new_ecn    like mfc_logical.
define variable ecm_recid  as recid.
define variable section    as integer.
define variable prog_name  like mnd_exec.
define variable prog_type  as character.
define variable sngl_yn    like mfc_logical.
define variable local_type like ecm_type.
define variable auto_nbr   like mfc_logical.
define variable i          as integer.
define variable msgnbr     like msg_nbr.
define variable warnlvl    as integer.
define variable len        as integer.
define variable del-yn     like mfc_logical initial no.
define variable mtitle     like mnt_label.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
{ecform01.i}
 SKIP(.4)  /*GUI*/
with frame a attr-space side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* NON-EXECUTABLE CODE TO ALLOW CORRECT CROSS REF INFO    */
if false then do:
   {gprun0.i ""ecclose.p""}
   {gprun0.i ""ecmttrl.p""}
end.

mainloop:
repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.

   view frame a.
   assign
      nbr       = ""
      ecmid     = ""
      dbase     = ""
      new_ecn   = no
      prog_name = "ecclose.p"
      section   = 0.

   nbrloop:
   do transaction on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      global_recid = ?.
      prompt-for
         ecm_nbr
         ecmid
         dbase
      with frame a
      editing:

         /* Allow last number refresh */
         if keyfunction(lastkey) = "RECALL" or lastkey = 307
         then
            display
               nbr @ ecm_nbr
            with frame a.

         {mfnp05.i ecm_mstr ecm_mstr
            "(ecm_eff_date = ?)"
            ecm_nbr "input ecm_nbr"}

         if global_recid <> ? then do:
            recno = global_recid.
            find ecm_mstr where recid(ecm_mstr) = recno.
            global_recid = ?.
         end.

         if recno <> ? then do:
            assign
               ecmid = substring(ecm_nbr,9,8)
               dbase = substring(ecm_nbr,17,8).

            display {ecform12.i} with frame a.
         end.
      end.
      global_recid = ?.

      assign ecmid dbase.

      nbr = string(input ecm_nbr, "x(8)")
          + string(ecmid, "x(8)")
          + string(dbase, "x(8)").

      find first ecm_mstr no-lock where ecm_nbr = nbr no-error.
      if not available ecm_mstr then do:
         {pxmsg.i &MSGNUM=2161 &ERRORLEVEL=3} /*PCO/PCR does not exist*/
         undo, retry.
      end.
      find first ecm_mstr exclusive-lock where ecm_nbr = nbr
         no-error no-wait.
      if locked (ecm_mstr) then do:
         {pxmsg.i &MSGNUM=7422 &ERRORLEVEL=4} /*Record Locked*/
         undo, retry.
      end.
      if ecm_eff_date <> ? then do:
         /* PCO has effective date.  Manual close not allowed */
         {pxmsg.i &MSGNUM=2182 &ERRORLEVEL=3}
         undo, retry.
      end.

      assign
         ecm_recid    = recid(ecm_mstr)
         ecm_userid   = global_userid
         ecm_mod_date = today.

      display
         {ecform12.i}
      with frame a.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.


   /*ecm_mstr is share-locked*/
   workloop:
   repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

      pause 0.
      prog_name = "ecmttrl.p".

      FORM /*GUI*/ 
         
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
ecm_nbr             colon 12 label "Number"
         ecmid               colon 36
         dbase               colon 58
         ecm_doc_type        colon 73 no-label format "x(3)"
         ecm_title           colon 12 skip
       SKIP(.4)  /*GUI*/
with frame b attr-space side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).

      hide all no-pause.
      /*GUI: view frame dtitle. */
IF global-tool-bar AND global-tool-bar-handle ne ? THEN
  view global-tool-bar-handle. /*GUI*/

      view frame b.

      display
         substring(ecm_nbr,1,8)  @ ecm_nbr
         substring(ecm_nbr,9,8)  @ ecmid
         substring(ecm_nbr,17,8) @ dbase
         ecm_doc_type
         ecm_title
      with frame b.

      do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.

         msgnbr = 0.
         {gprun.i prog_name "(input ecm_recid,
              input prog_type,
              input no,
              output msgnbr,
              output warnlvl)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      end.
/*GUI*/ if global-beam-me-up then undo, leave.

      if not available ecm_mstr then leave.

      if msgnbr <> 0 then do:
         {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=warnlvl}
         pause.
      end.

      hide all no-pause.
      /*GUI: view frame dtitle. */
IF global-tool-bar AND global-tool-bar-handle ne ? THEN
  view global-tool-bar-handle. /*GUI*/

      view frame a.
      display
         {ecform12.i}
      with frame a.

      leave workloop.

   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /*workloop*/

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /*mainloop*/

status input.
prog_name = "".
